home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes reversed ƒ / Mr. Do reversed.c < prev    next >
Text File  |  1994-04-19  |  4KB  |  182 lines

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define        BoxSize    4
  28. #define CorrectTime 1
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30. #define theWindowWidth (boundsRect.right-boundsRect.left)
  31.  
  32. pascal short MrDoReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  33.  
  34. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern,
  35.    starting with the center square, and alternatively scroll it up or down. */
  36.    
  37. pascal short MrDoReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  38. {
  39.     int            x, y;
  40.     int            vgap,hgap;
  41.     Rect        theRect, dest;
  42.     Rect        bounds[25];
  43.     Boolean        everyOther;
  44.     
  45.     vgap=theWindowHeight/5;
  46.     hgap=theWindowWidth/5;
  47.     
  48.     for (x=0; x<25; x++)
  49.     {
  50.         switch (x)
  51.         {
  52.             case 0:
  53.             case 1:
  54.             case 2:
  55.             case 3:
  56.             case 4:
  57.                 bounds[x].top=0;
  58.                 break;
  59.             case 15:
  60.             case 16:
  61.             case 17:
  62.             case 18:
  63.             case 5:
  64.                 bounds[x].top=vgap;
  65.                 break;
  66.             case 14:
  67.             case 23:
  68.             case 24:
  69.             case 19:
  70.             case 6:
  71.                 bounds[x].top=vgap*2;
  72.                 break;
  73.             case 13:
  74.             case 22:
  75.             case 21:
  76.             case 20:
  77.             case 7:
  78.                 bounds[x].top=vgap*3;
  79.                 break;
  80.             case 12:
  81.             case 11:
  82.             case 10:
  83.             case 9:
  84.             case 8:
  85.                 bounds[x].top=vgap*4;
  86.                 break;
  87.         }
  88.         switch (x)
  89.         {
  90.             case 0:
  91.             case 15:
  92.             case 14:
  93.             case 13:
  94.             case 12:
  95.                 bounds[x].left=0;
  96.                 break;
  97.             case 1:
  98.             case 16:
  99.             case 23:
  100.             case 22:
  101.             case 11:
  102.                 bounds[x].left=hgap;
  103.                 break;
  104.             case 2:
  105.             case 17:
  106.             case 24:
  107.             case 21:
  108.             case 10:
  109.                 bounds[x].left=hgap*2;
  110.                 break;
  111.             case 3:
  112.             case 18:
  113.             case 19:
  114.             case 20:
  115.             case 9:
  116.                 bounds[x].left=hgap*3;
  117.                 break;
  118.             case 4:
  119.             case 5:
  120.             case 6:
  121.             case 7:
  122.             case 8:
  123.                 bounds[x].left=hgap*4;
  124.                 break;
  125.         }
  126.         bounds[x].bottom=bounds[x].top+vgap;
  127.         bounds[x].right=bounds[x].left+hgap;
  128.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  129.     }
  130.     
  131.     for (y=24; y>=0; y--)
  132.     {        
  133.         if (!(y%2))   /* these scroll up */
  134.         {
  135.             dest=bounds[y];
  136.             dest.top=dest.bottom-BoxSize;
  137.             
  138.             theRect=bounds[y];
  139.             theRect.bottom=theRect.top+BoxSize;
  140.             
  141.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  142.             {
  143.                 StartTiming();
  144.                 ScrollTheRect(&bounds[y], 0, -BoxSize, 0L);
  145.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  146.                         &theRect, &dest, 0, 0L);
  147.                 theRect.bottom+=BoxSize;
  148.                 theRect.top+=BoxSize;
  149.                 if (everyOther)
  150.                     TimeCorrection(CorrectTime);
  151.                 everyOther=!everyOther;
  152.             }
  153.         }
  154.         else    /* these scroll down */
  155.         {
  156.             dest=bounds[y];
  157.             dest.bottom=dest.top+BoxSize;
  158.             
  159.             theRect=bounds[y];
  160.             theRect.top=theRect.bottom-BoxSize;
  161.             
  162.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  163.             {
  164.                 StartTiming();
  165.                 ScrollTheRect(&bounds[y], 0, BoxSize, 0L);
  166.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  167.                         &theRect, &dest, 0, 0L);
  168.                 theRect.bottom-=BoxSize;
  169.                 theRect.top-=BoxSize;
  170.                 if (everyOther)
  171.                     TimeCorrection(CorrectTime);
  172.                 everyOther=!everyOther;
  173.             }
  174.         }
  175.         
  176.         CopyBits(&(sourceGrafPtr->portBits),&(destGrafPtr->portBits),
  177.                     &bounds[y],&bounds[y],0,0L);
  178.     }
  179.     
  180.     return 0;
  181. }
  182.